package com.demo.services;

import com.demo.base.security.SecurityService;
import com.demo.dtos.SysResource;
import com.demo.dtos.SysRole;
import com.demo.dtos.SysRoleResourceLog;
import com.demo.mappers.SysRoleResourceLogMapper;
import com.demo.base.BaseServiceSupport;
import com.demo.base.IMapper;
import org.apache.commons.collections.MapUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Collection;
import java.util.HashMap;
import java.util.Map;

/**
 * 
 * SysRoleResourceLogService 业务处理类
 * @author BoomGred
 **/
@Service
public class SysRoleResourceLogService extends BaseServiceSupport<SysRoleResourceLog> implements SecurityService {
    @Autowired
    private SysRoleResourceLogMapper<SysRoleResourceLog> sysRoleResourceLogMapper;
    @Autowired
    private SysRoleService sysRoleService;
    @Autowired
    private SysResourceService sysResourceService;

    @Override
    public IMapper<SysRoleResourceLog> getMapper() {
        return sysRoleResourceLogMapper;
    }

    @Override
    public String getPK() {
        return "uuid";
    }

    @Override
    public Collection<SysRole> getAllRoleEntity() {
        return sysRoleService.list(MapUtils.EMPTY_MAP);
    }

    @Override
    public Collection<SysResource> findAllResources() {
        return sysResourceService.list(MapUtils.EMPTY_MAP);
    }

    @Override
    public Collection<SysRole> getRoleByResource(String resourceUuid) {
        Map map = new HashMap();
        map.put("resUuid",resourceUuid);
        return sysRoleResourceLogMapper.getRoleByResource(map);
    }
}